<template>
  <el-switch
    v-model="theme"
    class="mt-2"
    inline-prompt
    style="--el-switch-on-color: #f2f2f2; --el-switch-off-color: #2c2c2c"
    :active-icon="IconSun"
    :inactive-icon="IconMoon"
    @change="toggleDark()"
  />
</template>

<script setup >
import { ref } from 'vue'
import IconSun from '@/components/Icon/IconSun.vue'
import IconMoon from '@/components/Icon/IconMoon.vue'
import { useDark, useToggle ,useStorage} from '@vueuse/core'

const isDark = ref(useDark())
const toggleDark = useToggle(isDark)
const vueuseColorScheme = useStorage('vueuse-color-scheme')
const theme = vueuseColorScheme.value === 'dark' ? ref(false) : ref(true);

</script>

<style lang="less" scoped>
/deep/.el-switch__core .el-switch__inner .is-icon {
  font-size: 20px;
}
</style>